package com.cjk.ssm.controller;

import com.cjk.ssm.entity.Department;
import com.cjk.ssm.entity.Employee;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
public class ThmleafController {
    @RequestMapping("/t")
    public String test(Model model) {
        model.addAttribute("title","张同学");
        model.addAttribute("h","<h1>李同学</h1>");
        model.addAttribute("name","刘某某");

        Employee employee = new Employee();
        Department department = new Department();
        department.setDeptName("软工教研室");
        employee.setEmpName("陈某某");
        employee.setGender('男');
        employee.setDepartment(department);
        model.addAttribute("e",employee);

        boolean flag = false;
        model.addAttribute("flag",flag);

        Employee e1 = new Employee();
        e1.setEmpName("郭同学");
        Employee e2 = new Employee();
        e2.setEmpName("董同学");
        Employee e3 = new Employee();
        e3.setEmpName("路人甲");
        List<Employee> employees = new ArrayList<>();
        employees.add(e1);
        employees.add(e2);
        employees.add(e3);
        model.addAttribute("list",employees);

        return "test_thymleaf";
    }
}
